package etf.library;

import java.util.HashSet;
import java.util.Set;

public class Member {
	
	private String firstName;
	private String lastName;
	private int phoneNumber;
	private String email;
	private Library library;
	private Set<Book> rentedBooks = new HashSet<Book>(0);
	
	public Member(){
		
	}
	
	public Member(String firstName,String lastName,int phoneNumber,String email){
		this.firstName = firstName;
		this.lastName = lastName;
		this.phoneNumber = phoneNumber;
		this.email = email;
	}
	
	public void rentABook(Book book){
		rentedBooks.add(book);
	}
	
	public void returnARentedBook(Book book){
		if (rentedBooks.contains(book)) {
			book.removeARenter(this);
			rentedBooks.remove(book);
		}
	}
	
	public Book returnBookByTitle(String title){
		for (Book book : rentedBooks) {
			if (book.getTitle().equals(title)) {
				return book;
			}
		}
		return null;
	}
	
	public Set<Book> getRentedBooks() {
		return rentedBooks;
	}

	public void setRentedBooks(Set<Book> rentedBooks) {
		this.rentedBooks = rentedBooks;
	}

	public String getFirstName() {
		return firstName;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public int getPhoneNumber() {
		return phoneNumber;
	}
	public void setPhoneNumber(int phoneNumber) {
		this.phoneNumber = phoneNumber;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

	public void setLibrary(Library library) {
		this.library = library;
	}

	public Library getLibrary() {
		return library;
	}

}
